package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

   //这里重载了，管理端需要把所有的数据显示，所以status默认是null
    //用户端则只需要显示status为1
    List<Dish> listByCategoryId(Long categoryId,Integer status);
    default List<Dish> listByCategoryId(Long categoryId){
        return listByCategoryId(categoryId,null);
    }

    Page<DishVO> listWithCategory(Integer categoryId, String name, Integer status);


    List<Dish> list(Dish dish);
    DishVO getByIdWithCategory(Long id);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    void deleteBatch(List<Long> ids);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

//    @Update("update sky_take_out.dish set `status`=#{status} where id=#{id}")
//    void modifyStatus(Integer status, Long id);
}
